From: Simon McVittie Date: Wed, 17 Jan 2018 15:19:12 +0000 (+0000) Subject: tests/bootloader-entries-crosscheck: Use Python 3-friendly sorting X-Git-Tag: archive/raspbian/2022.1-3+rpi1~1^2~4^2~25^2~46 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:///%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:/?a=commitdiff_plain;h=6cabeaed3f45c8f3e05fb5e1152bfa5b96a3bc79;p=ostree.git tests/bootloader-entries-crosscheck: Use Python 3-friendly sorting This is a little clearer than a strcmp()-style negative/zero/positive return, and also works in Python 2. Signed-off-by: Simon McVittie Closes: #1457 Approved by: cgwalters --- diff --git a/tests/bootloader-entries-crosscheck.py b/tests/bootloader-entries-crosscheck.py index 38e8e451..5faa5487 100755 --- a/tests/bootloader-entries-crosscheck.py +++ b/tests/bootloader-entries-crosscheck.py @@ -38,8 +38,8 @@ def fatal(msg): sys.stderr.write('\n') sys.exit(1) -def compare_entries_descending(a, b): - return int(b['version']) - int(a['version']) +def entry_get_version(entry): + return int(entry['version']) def get_ostree_option(optionstring): for o in optionstring.split(): @@ -65,7 +65,7 @@ for fname in os.listdir(loaderpath): v = line[s+1:] entry[k] = v entries.append(entry) - entries.sort(compare_entries_descending) + entries.sort(key=entry_get_version, reverse=True) # Parse SYSLINUX config with open(syslinuxpath) as f: